﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace ViewLED.UI
{
    /// <summary>
    /// VideoEle.xaml 的交互逻辑
    /// </summary>
    public partial class VideoEle : UserControl
    {
        private bool IsPlaying;
        private int stretchType;

        public VideoEle()
        {
            InitializeComponent();
        }

        public bool isPlaying
        {
            get { return IsPlaying; }
            set { IsPlaying = value; }
        }

        public int StretchType
        {
            get { return stretchType; }
            set
            {
                stretchType = value;
                setStretchType(stretchType);
            }
        }

        // 定义播放结束时触发的变化
        private void mediaVideo_MediaEnded(object sender, RoutedEventArgs e)
        {
            IsPlaying = false;
        }

        // 定义缩放类型
        private void setStretchType(int index)
        {
            switch (index)
            {
                case 0:
                    mediaVideo.Stretch = Stretch.None;
                    break;
                case 1:
                    mediaVideo.Stretch = Stretch.Fill;
                    break;
                case 2:
                    mediaVideo.Stretch = Stretch.Uniform;
                    break;
                case 3:
                    mediaVideo.Stretch = Stretch.UniformToFill;
                    break;
            }
        }
    }
}
